home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / burnout.arc / BURNOUT.ASM < prev    next >
Assembly Source File  |  1985-11-28  |  5KB  |  133 lines

  1. COMMENT *
  2.  
  3.   Demo (and semi-useful) program to read/set burnout device parameters.
  4.  
  5.   Usage: burnout [ticks] [C+-] [V+-] [H+-]
  6.  
  7.   Parameters can be separated by almost anything.
  8.   With no parameters, program simply returns current status.
  9.  
  10.   Examples:
  11.     burnout 5000                (sets time to 5000 ticks)
  12.     burnout 5000H+              (time=5000, use hardware blanking)
  13.     burnout 5000,h+             (ditto, separators don't matter)
  14.     burnout c+h-v+              (continuous clear, software, monitor video)
  15.     burnout /C+ /H- /V+         (ditto)
  16.     burnout                     (return status only)
  17.  
  18.   Assembly/link:
  19.     masm burnout;
  20.     link burnout;  (ignore NO STACK warning message)
  21.     exe2bin burnout burnout.com
  22.  
  23.   By CJDunford  20-Mar-1985
  24.      Compuserve 76703,2002
  25.  
  26. ======================================================================
  27. *
  28.  
  29. stdout equ 1                            ; DOS output files
  30. stderr equ 2
  31.  
  32. ; ----- General equates
  33. DOS         equ 21H                     ; DOS interrupt
  34. TERMINATE   equ 20H                     ; Exit to DOS
  35.  
  36. PRINT       equ 09H                     ; DOS "print" string to stdout
  37. FOPEN       equ 3D02H                   ; DOS file open, read/write
  38. FREAD       equ 3FH                     ; DOS file read
  39. FWRITE      equ 40H                     ; DOS file write
  40.  
  41. CR          equ 13                      ; ASCII carriage return
  42. LF          equ 10                      ; ASCII line fine
  43.  
  44. code segment
  45. assume cs:code,ds:code
  46.  
  47. org 80H                                 ; Parm storage area in PSP
  48. ParmLength label byte                   ; Length of parms
  49. org 81H
  50. Parameters label byte                   ; Start of parms
  51.  
  52. org 100H                                ; Org for .COM
  53. main proc far
  54.         jmp start                       ; Hate to execute data
  55.  
  56. DevName         db 'BRNDEV',0           ; Burnout device name
  57. handle          dw ?                    ; Storage for handle
  58. Flush           db '@'                  ; Char to flush device I/O
  59. Execute         db '#'                  ; Char to execute device commands
  60.  
  61. NotInstalled    db 'Burnout device is not installed',13,10
  62. NotInstalledL   equ $ - NotInstalled
  63.  
  64. Status          db 'Current status: '   ; Status message
  65. StatInsert      db 40 dup (?)           ; brndev will store status here
  66.  
  67. ; ----- Open the device
  68. start:
  69.         mov dx,offset DevName           ; DS:DX => device name
  70.         mov ax,FOPEN
  71.         int DOS
  72.         jnc A1                          ; Continue if no error
  73.         mov bx,stderr                   ; Message to stderr
  74.         mov cx,NotInstalledL
  75.         mov dx,offset NotInstalled
  76.         mov ah,FWRITE
  77.         int DOS
  78.         jmp exit
  79.  
  80. ; ----- Flush any pending I/O to/from the device
  81. A1:
  82.         mov handle,ax                   ; Save device handle
  83.         mov dx,offset Flush             ; Point to the "@"
  84.         mov cx,1                        ; Writing one byte
  85.         mov bx,handle                   ; Device handle
  86.         mov ah,FWRITE                   ; Write "@" to device
  87.         int DOS
  88.  
  89. ; ----- Send and execute parameters if present
  90.         mov cl,ParmLength               ; Parm length to CL
  91.         or cl,cl                        ; Any parms present?
  92.         jz A2                           ; Skip if not
  93.         xor ch,ch                       ; CX = parm length
  94.         mov dx,offset Parameters        ; DS:DX => parms
  95.         mov bx,handle                   ; BX = device handle
  96.         mov ah,FWRITE                   ; Write parms to device
  97.         int DOS
  98.  
  99.         mov dx,offset Execute           ; Execute the parms
  100.         mov cx,1                        ; Writing one byte
  101.         mov bx,handle                   ; Device handle
  102.         mov ah,FWRITE                   ; Write "#" to device
  103.         int DOS
  104.  
  105. ; ----- Get and display device status
  106. A2:
  107.         mov dx,offset StatInsert        ; DS:DX => where to put status
  108.         mov cx,0FFH                     ; Ask for lots of data; DOS will ...
  109.                                         ; ... fetch only until CR found.
  110.         mov bx,handle                   ; Device handle
  111.         mov ah,FREAD                    ; Read device info
  112.         int DOS
  113.  
  114.         mov cx,ax                       ; CX = actual # bytes read
  115.         mov di,offset StatInsert        ; Where the stat data is stored
  116.         add di,cx                       ; Add length of input read
  117.         mov al,CR                       ; Store a CR/LF/'$' at end
  118.         cld
  119.         stosb
  120.         mov al,LF
  121.         stosb
  122.         mov al,'$'
  123.         stosb
  124.         mov dx,offset Status            ; Write status to stdout
  125.         mov ah,PRINT
  126.         int DOS
  127.  
  128. exit:
  129.         int TERMINATE                   ; Exit to DOS
  130. main endp
  131. code ends
  132. end main
  133.